package com.infore.siteManagement.entity;

import java.io.Serializable;
import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.infore.siteManagement.entity.otherEntity.Instructions;

import java.util.Date;
import java.util.Set;


/**
 * The persistent class for the EQUIPMENT database table.
 * 设备实体类
 * llf
 */
@NamedEntityGraph(name="equipment_view",
	attributeNodes={
		@NamedAttributeNode("equipmentType"),
		@NamedAttributeNode(value ="projects",subgraph ="projects_view"),
		@NamedAttributeNode(value ="station",subgraph ="station_view"),
		@NamedAttributeNode(value ="instructions")
	},
	subgraphs = {
		@NamedSubgraph(name="station_view",
		attributeNodes = {
				@NamedAttributeNode(value = "area", subgraph = "area_view"),
				@NamedAttributeNode(value ="provinceId", subgraph = "area_view"),
				@NamedAttributeNode(value ="cityId", subgraph = "area_view"),
				@NamedAttributeNode("basinn"),
				@NamedAttributeNode("stationType"),
				@NamedAttributeNode("stationClassify"),
				@NamedAttributeNode(value = "equipment"),
				@NamedAttributeNode(value = "projects",subgraph ="projects_view"),
				@NamedAttributeNode("protocols")
		}
		),
		@NamedSubgraph(name="projects_view",
		attributeNodes = {
			@NamedAttributeNode(value="projectType")
		}
		),
		@NamedSubgraph(name="area_view",
		attributeNodes = {
			@NamedAttributeNode(value="areaLevel")
		}
		),
	}
)
@Entity
@Table(name = "EQUIPMENT")
@NamedQuery(name="Equipment.findAll", query="SELECT e FROM Equipment e")
public class Equipment implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name="EQUIPMENT_ID")
	@GeneratedValue(generator = "uuidGenerator")
	@GenericGenerator(name = "uuidGenerator", strategy = "uuid") // UUID生成策略
	private String equipmentId;

	/** 安装时间**/
	@Temporal(TemporalType.TIMESTAMP)
	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") 
	@Column(name="CREATE_TIME")
	private Date createTime;

	/** 仪器类型号名称**/
	@Column(name="EQUIPMENT_TYPE_NAME")
	private String equipmentTypeName;

	/** 仪器名称**/
	@Column(name="EQUIPMENT_NAME")
	private String equipmentName;

	/** 仪器类型id**/
	@ManyToOne(cascade = CascadeType.MERGE) 
	@JoinColumn(name = "EQUIPMENT_TYPE_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	private EquipmentType equipmentType;

	/** 固定资产编号**/
	@Column(name="FIXED_ASSETS_CODE")
	private String fixedAssetsCode;

	/** 出厂编号**/
	@Column(name="MANUFACTURE_CODE")
	private String manufactureCode;
	
	/**因子/指标信息**/
	@JsonIgnoreProperties
	@ManyToMany(targetEntity = Project.class)//,cascade = CascadeType.MERGE
	@JoinTable(name = "PROJECT_AND_EQUIPMENT", joinColumns = @JoinColumn(name = "EQUIPMENT_ID"), 
	inverseJoinColumns = @JoinColumn(name = "PROJECT_ID")) 
	private Set<Project> projects;
	
	/** 站点**/
	@JsonIgnoreProperties
	@ManyToOne
	@JoinColumn(name = "STATION_MN",referencedColumnName="STATION_MN",  insertable = false, updatable = false)
	@NotFound(action = NotFoundAction.IGNORE)
	private Station station;
	
	/**站点mn*/
	@Column(name="STATION_MN")
	private String stationMn;
	
	/**站点名称*/
	@Column(name="STATION_NAME")
	private String stationName;
	
	/**指令**/
	@JsonIgnoreProperties("equipment_Instructions")
	@ManyToMany(targetEntity = Instructions.class)//,cascade = CascadeType.MERGE
	@JoinTable(name = "EQUIPMENT_AND_INSTRUCTIONS", joinColumns = @JoinColumn(name = "EQUIPMENT_ID"), 
	inverseJoinColumns = @JoinColumn(name = "INSTRUCTIONS_ID")) 
	private Set<Instructions> instructions;
	
	/**仪器厂家*/
	@Column(name="MANUFACTOR")
	private String manufactor;
	
	/**是否启用1是0否*/
	@Column(name="ISENABLE")
	private String isenable;
	
	/**录入人*/
	@Column(name="CREATE_PEOPLE")
	private String createPolple;
	
	/**录入人名称*/
	@Column(name="CREATE_NAME")
	private String createName;
	
	/**录入时间*/
	@Temporal(TemporalType.TIMESTAMP)
	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") 
	@Column(name="CREATE_PEOPLE_TIME")
	private Date createPeopleTime;
	
	/** 仪器型号**/
	@Column(name="EQUIPMENT_MODEL")
	private String equipmentModel;
	
	/** 仪器量程**/
	@Column(name="EQUIPMENT_ORANGE")
	private String equipmentOrange;

	public Equipment() {
	}

	public String getEquipmentId() {
		return equipmentId;
	}

	public void setEquipmentId(String equipmentId) {
		this.equipmentId = equipmentId;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public String getEquipmentTypeName() {
		return equipmentTypeName;
	}

	public void setEquipmentTypeName(String equipmentTypeName) {
		this.equipmentTypeName = equipmentTypeName;
	}

	public String getEquipmentName() {
		return equipmentName;
	}

	public void setEquipmentName(String equipmentName) {
		this.equipmentName = equipmentName;
	}

	public EquipmentType getEquipmentType() {
		return equipmentType;
	}

	public void setEquipmenttype(EquipmentType equipmentType) {
		this.equipmentType = equipmentType;
	}

	public String getFixedAssetsCode() {
		return fixedAssetsCode;
	}

	public void setFixedAssetsCode(String fixedAssetsCode) {
		this.fixedAssetsCode = fixedAssetsCode;
	}

	public String getManufactureCode() {
		return manufactureCode;
	}

	public void setManufactureCode(String manufactureCode) {
		this.manufactureCode = manufactureCode;
	}

	public Set<Project> getProjects() {
		return projects;
	}

	public void setProjects(Set<Project> projects) {
		this.projects = projects;
	}

	public Station getStation() {
		return station;
	}

	public void setStation(Station station) {
		this.station = station;
	}

	public String getStationMn() {
		return stationMn;
	}

	public void setStationMn(String stationMn) {
		this.stationMn = stationMn;
	}

	public String getStationName() {
		return stationName;
	}

	public void setStationName(String stationName) {
		this.stationName = stationName;
	}

	public Set<Instructions> getInstructions() {
		return instructions;
	}

	public void setInstructions(Set<Instructions> instructions) {
		this.instructions = instructions;
	}

	public String getManufactor() {
		return manufactor;
	}

	public void setManufactor(String manufactor) {
		this.manufactor = manufactor;
	}

	public String getIsenable() {
		return isenable;
	}

	public void setIsenable(String isenable) {
		this.isenable = isenable;
	}

	public String getCreatePolple() {
		return createPolple;
	}

	public void setCreatePolple(String createPolple) {
		this.createPolple = createPolple;
	}

	public String getCreateName() {
		return createName;
	}

	public void setCreateName(String createName) {
		this.createName = createName;
	}

	public Date getCreatePeopleTime() {
		return createPeopleTime;
	}

	public void setCreatePeopleTime(Date createPeopleTime) {
		this.createPeopleTime = createPeopleTime;
	}

	public String getEquipmentModel() {
		return equipmentModel;
	}

	public void setEquipmentModel(String equipmentModel) {
		this.equipmentModel = equipmentModel;
	}

	public String getEquipmentOrange() {
		return equipmentOrange;
	}

	public void setEquipmentOrange(String equipmentOrange) {
		this.equipmentOrange = equipmentOrange;
	}

}